from os.path import pathsep

import requests
import json
# #起点坐标
# url1 = ("https://restapi.amap.com/v3/geocode/geo?address=暨南大学"
#         "番禺校区&key=30ba721c7ba0a57604a12466dab49dc1")
# response = requests.get(url1).text
# data1 = json.loads(response)
#
# print(data1)
#
# if "geocodes" in data1:
#     geocodes = data1['geocodes'][0]
#     if "location" in geocodes:
#         start = geocodes['location']
#         print(start)
#
# #终点坐标
# url1 = ("https://restapi.amap.com/v3/geocode/geo?address=暨南大学石牌校"
#         "区&key=30ba721c7ba0a57604a12466dab49dc1")
# response = requests.get(url1).text
# data2 = json.loads(response)
#
# print(data2)
#
# if "geocodes" in data2:
#     geocodes = data2['geocodes'][0]
#     if "location" in geocodes:
#         end = geocodes['location']
# #         print(end)
#
#导航
url2 =("https://restapi.amap.com/v5/direction/driving?"
       "key=30ba721c7ba0a57604a12466dab49dc1&origin=113.419003,23.020406&"
       "destination=113.352241,23.137452&strategy=0")
option = requests.get(url2).text
way = json.loads(option)
print(type(option))
if 'route' in way:
    route = way['route']
    paths = route["paths"]
    paths_1 = paths[-1]
    steps = paths_1['steps']
    for i in steps:
        print(i)




